if (!OMSystem) var OMSystem = { };
if (!OMSystem.OrkutManager) OMSystem.OrkutManager = { };
if (!OMSystem.OrkutManager.Toolbar) OMSystem.OrkutManager.Toolbar = { };

OMSystem.OrkutManager.Toolbar =
{
	Get:
	function ()
	{
		var Language = OMSystem.OrkutManager.Language.Get();
		var User = OMSystem.OrkutManager.Util.User;
		var PrefManager	= OMSystem.OrkutManager.PrefManager;
		
		IsSmilyey = 'smiley/';	
		if (PrefManager.Get("omOLDemoticons")){ 
				IsSmilyey = '';
		}
						
		var Separator = "<span class='Sep'>&nbsp;</span>";
		var ToolbarSetSelectedTextValue = "  function omSetSelectedTextValue(val) { var s, e; s = post.selectionStart; e = post.selectionEnd; post.value = post.value.substr(0, s) + val + post.value.substr(e); post.selectionStart = s; post.selectionEnd = s + (val.length); post.focus(); post.scrollTop = (14 * post.value.substr(0, post.selectionStart).match(/\\n/g).length); } " +
		"function omSetSelectedTextFormat(val) { var s, e; s = post.selectionStart; e = post.selectionEnd; post.value = post.value.substr(0, s) + (val.replace('{|}', psel)) + post.value.substr(e); post.selectionStart = (s + val.lastIndexOf('{|}')); post.selectionEnd = post.selectionStart + (psel.length); post.focus(); post.scrollTop = (14 * post.value.substr(0, post.selectionStart).match(/\\n/g).length);} ";

		var ToolbarFontJS = "post.value = post.value.substr(0, post.selectionStart) + '<span style=\\'font-family:' + (this.value || this.getAttribute('value')) + '\\'>{|}</span>' + post.value.substr(post.selectionEnd); var focus = post.value.lastIndexOf('{|}'); post.value = post.value.replace('{|}', psel); post.selectionStart = focus; post.selectionEnd = focus + psel.length; post.focus();\" onmouseover=\"this.parentNode.value=this.value;\" ";
		var ToolbarFontJSIconClick = " var tob = this; do { tob = tob.parentNode; } while (tob && tob.className != 'OMToolbar'); var x = tob; var ss = tob.getElementsByTagName('span'); for each(var s in ss) { if (s.getAttribute('name') == 'OMToolbarFontIcon') { x = s; break; } } x = x.options[x.selectedIndex].value; omSetSelectedTextFormat('<span style=\\'font-family:' + x + '\\'>{|}</span>'); ";
		var ToolbarFontSizeJS = " omSetSelectedTextFormat('<span style=\\'font-size:' + this.value + 'px\\'>{|}</span>'); ";
		var ToolbarFontSizeJSIconClick = " var tob = this; do { tob = tob.parentNode; } while (tob && tob.className != 'OMToolbar'); var x = tob; var ss = tob.getElementsByTagName('span'); for each(var s in ss) { if (s.getAttribute('name') == 'OMToolbarFontSizeIcon') { x = s; break; } } x = x.options[x.selectedIndex].value; omSetSelectedTextFormat('<span style=\\'font-size:' + x + 'px\\'>{|}</span>'); ";
		var ToolbarHighlightJS = " omSetSelectedTextFormat('<span style=\\'background-color:' + this.style.backgroundColor + '\\'>{|}</span>');  this.parentNode.selectedIndex=0; \"  onmouseover=\"var tob = this; do { tob = tob.parentNode; } while (tob && tob.className != 'OMToolbar'); var x = tob; var ss = tob.getElementsByTagName('span'); for each(var s in ss) { if (s.getAttribute('name') == 'OMToolbarHightlight') { x = s; break; } } x.style.backgroundColor= this.style.backgroundColor;";
		var ToolbarColorHTJS = " omSetSelectedTextFormat('<span style=\\'color:' + this.style.backgroundColor + '\\'>{|}</span>'); this.parentNode.selectedIndex=0;\" onmouseover=\"var tob = this; do { tob = tob.parentNode; } while (tob && tob.className != 'OMToolbar'); var x = tob; var ss = tob.getElementsByTagName('span'); for each(var s in ss) { if (s.getAttribute('name') == 'OMToolbarColor') { x = s; break; } } x.style.backgroundColor=this.style.backgroundColor;\" ";
		var ToolbarshadowJS = " omSetSelectedTextFormat('<span style=\\'text-shadow:' + this.style.textShadow + '\\'>{|}</span>');  this.parentNode.selectedIndex=0; \"  onmouseover=\"var tob = this; do { tob = tob.parentNode; } while (tob && tob.className != 'OMToolbar'); var x = tob; var ss = tob.getElementsByTagName('span'); for each(var s in ss) { if (s.getAttribute('name') == 'shadowToolbar') { x = s; break; } } x.style.textShadow= this.style.textShadow;";
		var ToolbarColorJS = " omSetSelectedTextFormat('[' + this.style.backgroundColor + ']{|}[/' + this.style.backgroundColor + ']'); this.parentNode.selectedIndex=0;\" onmouseover=\"var tob = this; do { tob = tob.parentNode; } while (tob && tob.className != 'OMToolbar'); var x = tob; var ss = tob.getElementsByTagName('span'); for each(var s in ss) { if (s.getAttribute('name') == 'OMToolbarColor') { x = s; break; } }  x.style.backgroundColor=this.style.backgroundColor;\"";
		var ToolbarEmoticonJS = " omSetSelectedTextFormat('[' + (this.value || this.getAttribute('value')) + ']{|}');\" onmouseover=\"var tob = this; do { tob = tob.parentNode; } while (tob && tob.className != 'OMToolbar'); var x = tob; var ss = tob.getElementsByTagName('span'); for each(var s in ss) { if (s.getAttribute('name') == 'OMToolbarEmoticonSelect') { x = s; break; } } this.parentNode.value=this.value; var x1 = tob; var ss = tob.getElementsByTagName('span'); for each(var s in ss) { if (s.getAttribute('name') == 'OMToolbarEmoticon') { x1 = s; break; } } x1.setAttribute('value', x.options[x.selectedIndex].value); x1.src=";
		var ToolbarEmoticonJS2 = " omSetSelectedTextFormat('<img src=\\'' + this.getAttribute('href') + '\\' alt=\\'' + this.value + '\\' />');";
		var ToolbarNewLine = "<div style='height:8px;width:1px;clear:both;'><br/></div>";
		var ToolbarJS = "var post = this; do { post = post.parentNode; } while (post && post.className != 'OMToolbar'); var tob = post; post = post.parentNode.getElementsByTagName('textarea')[0]; var psel = post.value.substr((post.selectionStart), (post.selectionEnd - post.selectionStart)); " + ToolbarSetSelectedTextValue + " ";		
		var EmoteList = '';
		var prefMenu = JSON.parse(OMSystem.OrkutManager.PrefManager.Get("EmoticonsList", ""));
		for each(var pm in prefMenu)
		{
			var EmoteList = EmoteList + "<option href='"+unescape(pm.split("|")[1])+"' onclick=\"" + ToolbarJS + ToolbarEmoticonJS2 + "\" style='background-image: url("+unescape(pm.split("|")[1])+"); background-repeat: no-repeat; background-position: left; padding-left: 20px;'>"+unescape(pm.split("|")[0])+"</option>";
		}		
		var Toolbar =
		{
			Tools: 
				new Array(
					new Array /* Collapsebar */
					(
						"<span title='" + Language.ToolbarCollapse + "' style='font-weight:bold;font-family:tahoma;float:right; margin-top: -5px; width: 20px; margin-left:10px;' " +
						"onclick=\"if (this.innerHTML.indexOf('-') >= 0) { this.parentNode.parentNode.style.height='5px'; this.innerHTML = '+'; } "+
						"else { this.parentNode.parentNode.style.height='auto'; this.innerHTML = '-'; }\" " +
						">-</span>",
						"{|}",
						"{|}",
						"false"
					),
					new Array /* Set Field Size */
					(
						"<span class='SizeSet Icon' style='float: right !important' " +
						"onclick=\"" + ToolbarJS + " var h = prompt('#'); if (h > 0 && h < 999999999) post.style.height = (h) + 'px';  \" " +
						">&nbsp;</span>",
						"{|}",
						"{|}",
						"false"
					),
					new Array /* -- Field Size */
					(
						"<span class='SizeDec Icon' style='float: right !important' " +
						"onclick=\"" + ToolbarJS + " post.style.height = (post.offsetHeight - 200) + 'px';  \" " +
						">&nbsp;</span>",
						"{|}",
						"{|}",
						"false"
					),
					new Array /* ++ Field Size */
					(
						"<span class='SizeInc Icon' style='float: right !important' " +
						"onclick=\"" + ToolbarJS + " post.style.height = (post.offsetHeight + 200) + 'px';  \" " +
						">&nbsp;</span>",
						"{|}",
						"{|}",
						"false"
					),
					new Array /* Bold */
					(
						"<span title='" + Language.ToolbarBold +
							"' class='Bold Icon'>&nbsp;</span>",	// Display Button
						"<b>{|}</b>",								// HTML code ;  {|} = Cursor	; empty to disable from html
						"[b]{|}[/b]",								// code		 ;	{|} = Cursor	; empty to disable from normal
						"true"										// false	 = 	tell not to use codes, use button script
					),
					new Array /* Italic */
					(
						"<span title='" + Language.ToolbarItalic + "' class='Italic Icon'>&nbsp;</span>",
						"<i>{|}</i>",
						"[i]{|}[/i]"
					),
					new Array /* Underline */
					(
						"<span title='" + Language.ToolbarUnderline + "' class='Underline Icon'>&nbsp;</span>",
						"<u>{|}</u>",
						"[u]{|}[/u]"
					),
					new Array /* Strike */
					(
						"<span title='" + Language.ToolbarStrike + "' class='Strike Icon'>&nbsp;</span>",
						"<s>{|}</s>",
						""
					),
					new Array /* Strike fake (no-html) */
					(
						"<span title='" + Language.ToolbarStrike + "' class='Strike Icon' onclick=\"" + ToolbarJS + "function ToolbarStrikeFake(s){var i = 0;var x = 0;var f ='';for (i=0;i<s.length;++i){x = s.charCodeAt(i); f += String.fromCharCode(x) + String.fromCharCode(822);}return f;} post.value = post.value.substr(0, post.selectionStart) + ToolbarStrikeFake(psel) + post.value.substr(post.selectionEnd); var focus = post.value.lastIndexOf('{|}'); post.value = post.value.replace('{|}', psel); post.selectionStart = focus; post.selectionEnd = focus + psel.length; post.focus();\" " +
						">&nbsp;</span>",
						"",
						"{|}"
					),
					new Array /* Align:: Left */
					(
						Separator +
						"<span title='" + Language.ToolbarAlignLeft + "' class='AlignLeft Icon'>&nbsp;</span>",
						"<div style=\\'text-align:left\\'>{|}</div>",
						""
					),
					new Array /* Align:: Center */
					(
						"<span title='" + Language.ToolbarAlignCenter + "' class='AlignCenter Icon'>&nbsp;</span>",
						"<center>{|}</center>",
						""
					),
					new Array /* Align:: Right */
					(
						"<span title='" + Language.ToolbarAlignRight + "' class='AlignRight Icon'>&nbsp;</span>",
						"<div style=\\'text-align:right\\'>{|}</div>",
						""
					),
					new Array /* Align:: Justify */
					(
						"<span title='" + Language.ToolbarAlignJustify + "' class='AlignJustify Icon'>&nbsp;</span>",
						"<div style=\\'text-align:justify\\'>{|}</div>",
						""
					),
					new Array /* Separator */
					(
						Separator,
						"{|}",
						"{|}"
					),
					new Array /* Blink */
					(
						"<span title='" + Language.ToolbarBlink + "' class='Blink Icon'>&nbsp;</span>",
						"<span style=\\'text-decoration:blink\\'>{|}</span>",
						""
					),
					new Array /* Separator */
					(
						Separator,
						"{|}",
						""
					),
					new Array /* Link */
					(
						"<span title='" + Language.ToolbarLink + "' class='Link Icon'>&nbsp;</span>",
						"<a href=\\'{|}\\' title=\\'\\'></a>",
						"[link={|}][/link]"
					),
					new Array /* Image */
					(
						"<span title='" + Language.ToolbarImage + "' class='Image Icon'>&nbsp;</span>",
						"<img src=\\'{|}\\' style=\\'max-width:100%\\' />",
						"[link]{|}[/link]"
					),
					new Array /* Source */
					(
						"<span title='" + Language.ToolbarSource + "' class='Source Icon'>&nbsp;</span>",
						"<div style=\\'border:1px dashed #2F6FAB;padding:5px;background-color:#F9F9F9;\\'><pre style=\\'margin:0px;padding:1em;overflow:scroll;width:97%;font-size:88%\\'>[code]{|}[/code]</pre></div>",
						"[code]{|}[/code]"
					),
					new Array /* Spoilers */
					(
						"<span title='" + Language.ToolbarSpoiler + "' class='Spoiler Icon'>&nbsp;</span>",
						"<div style=\\'border:1px solid #FFCC66;margin:10px 0px;padding:5px 3px;background-color:#FFFDDF;text-align:left;font-size:90%;\\'>" + Language.SpoilerText + "</div>[yellow]{|}[/yellow]",
						"[red][b]/!\\\\ SPOILERS /!\\\\[/b][/red]\\n[yellow]{|}[/yellow]"
					),
					new Array /* Quotes */
					(
						"<span title='" + Language.ToolbarQuote + "' class='Quote Icon'>&nbsp;</span>",
						"<q style=\\'font-style:italic;\\'>{|}</q>",
						""
					),
					new Array /* Separator */
					(
						Separator,
						"{|}",
						"{|}"
					),
					new Array /* New Line */
					(
						"<span class='Br Icon' title='" + Language.ToolbarNewLine + "'>&nbsp;</span>",
						"<br/>{|}",
						""
					),
					new Array /* Separator */
					(
						Separator,
						"{|}",
						""
					),
					new Array /* Encrypt */
					(
						"<span title='" + Language.ToolbarEncrypt + "' class='Encrypt Icon' onclick=\"" + ToolbarJS + "function crypt(s, secret){var i = 0;var x = 0;var f ='';for (i=0;i<s.length;++i){x = s.charCodeAt(i);f += String.fromCharCode(x+secret);}return f;} omSetSelectedTextValue(crypt(psel, 77));\">&nbsp;</span>",
						"{|}",
						"{|}"
					),
					new Array /* Decrypt */
					(
						"<span title='" + Language.ToolbarDecrypt + "' class='Decrypt Icon' onclick=\"" + ToolbarJS + "function crypt(s, secret){var i = 0;var x = 0;var f ='';for (i=0;i<s.length;++i){x = s.charCodeAt(i);f += String.fromCharCode(x+secret);}return f;} omSetSelectedTextValue(crypt(psel, -77));\">&nbsp;</span>",
						"{|}",
						"{|}"
					),
					new Array /* Separator */
					(
						Separator,
						"{|}",
						"{|}"
					),
					new Array /* Time */
					(
						"<span title='" + Language.ToolbarTime + "' class='Time Icon' onclick=\"" + ToolbarJS + " function omTime(format) { format = unescape(format); function LeadZero(v) {  return (v < 10 ? '0' + v : v); } var date = new Date();  var d = LeadZero(date.getDate()); var j = date.getDate(); var w = date.getDay(); var l; switch (w) { case 0: l = '" + (Language.DateTimeDays[0]) + "'; break; case 1: l = '" + (Language.DateTimeDays[1]) + "'; break; case 2: l = '" + (Language.DateTimeDays[2]) + "'; break; case 3: l = '" + (Language.DateTimeDays[3]) + "'; break; case 4: l = '" + (Language.DateTimeDays[4]) + "'; break; case 5: l = '" + (Language.DateTimeDays[5]) + "'; break; case 6: default: l = '" + (Language.DateTimeDays[6]) + "'; break; }; var D = l.substring(0, 3);  var m = LeadZero(date.getMonth() + 1); var n = (date.getMonth() + 1); var F; switch ((n - 1)) { case 0: F = '" + (Language.DateTimeMonths[0]) + "'; break; case 1: F = '" + (Language.DateTimeMonths[1]) + "'; break; case 2: F = '" + (Language.DateTimeMonths[2]) + "'; break; case 3: F = '" + (Language.DateTimeMonths[3]) + "'; break; case 4: F = '" + (Language.DateTimeMonths[4]) + "'; break; case 5: F = '" + (Language.DateTimeMonths[5]) + "'; break; case 6: F = '" + (Language.DateTimeMonths[6]) + "'; break; case 7: F = '" + (Language.DateTimeMonths[7]) + "'; break; case 8: F = '" + (Language.DateTimeMonths[8]) + "'; break; case 9: F = '" + (Language.DateTimeMonths[9]) + "'; break; case 10: F = '" + (Language.DateTimeMonths[10]) + "'; break; case 11: default: F = '" + (Language.DateTimeMonths[11]) + "'; break; }; var M = F.substring(0, 3);  function YearLeap(y) {  if ((y % 4) == 0)  {   if ((y % 100) == 0)    return ((y % 400) == 0) ? 1 : 0;   else    return 1;  }  else return 0; }  var Y = date.getFullYear() + ''; var y = Y.substring(2); var L = YearLeap(Y); var H = date.getHours(); var h = (H > 12) ? (H - 12) : (H); var G = H; var g = h; var A = (H > 12) ? 'PM' : 'AM'; var a = A.toLowerCase(); H = LeadZero(H); h = LeadZero(h);  var i = LeadZero(date.getMinutes());  var s = LeadZero(date.getSeconds()); var B = date.getMilliseconds();  return format.replace(/%d/g, d).replace(/%j/g, j).replace(/%w/, w).replace(/%l/g, l).replace(/%D/g, D).replace(/%m/g, m).replace(/%n/g, n).replace(/%F/g, F).replace(/%M/g, M).replace(/%Y/g, Y).replace(/%y/g, y).replace(/%L/g, L).replace(/%H/g, H).replace(/%h/g, h).replace(/%G/g, G).replace(/%g/g, g).replace(/%A/g, A).replace(/%a/g, a).replace(/%i/g, i).replace(/%s/g, s).replace(/%B/g, B);} omSetSelectedTextValue(omTime('" + escape(OMSystem.OrkutManager.PrefManager.Get("TimeFormat")) + "')); \">&nbsp;</span>",
						"{|}",
						"{|}"
					),
					new Array /* Mask Links */
					(
						"<span class='FixLinks Icon' title='" + Language.ToolbarMaskLinks + "' " +
						"onclick=\"" +
						ToolbarJS +
						" post.value = post.value.replace(/(https?:\\/)()(\\/)/gi, '$1[b]$2[/b]$3'); " +
						" post.value = post.value.replace(/\\b([.])/ig,'[b]$1[/b]'); " +
						"\"" +
						">&nbsp;</span>",
						"{|}",
						"{|}"
					),
					new Array /* Toolbar Layout: New Line */
					(
						ToolbarNewLine,
						"{|}",
						""
					),
					new Array /* Highlight HTML */
					(
						"<span class='Highlight Icon' title='" + Language.ToolbarColorPicker + "' name='OMToolbarHightlight' style='background-color: yellow;' onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\">&nbsp;</span> <select class='HighlightSelect'>" +
							"<option disabled selected>" + "Highlight" + "</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\" style='background-color: maroon'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: red'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: orange'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: navy'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: blue'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: aqua'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: teal'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: green'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: lime'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: olive'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: gold'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: yellow'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: gray'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: silver'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: purple'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: fuchsia'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: violet'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarHighlightJS + "\"  style='background-color: pink'>&nbsp;</option>" +
						"</select>",
						"{|}",
						"",
						"false",
						"true"
					),
					new Array /* Text Shadow */
					(
						"<span class='Shadow Icon' title='Text-shadow' name='shadowToolbar' style='text-shadow: 0px 0px 5px blue;' onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"></span> <select class='ShadowSelect'>" +
							"<option disabled selected>" + "Text-shadow" + "</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px blue;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px black;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px white;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px green;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px pink;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px maroon;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px red;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px orange;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px navy;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px aqua;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px teal;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px lime;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px olive;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px gold;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px yellow;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px purple;'>Text-shadow</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarshadowJS + "\"  style='text-shadow: 0px 0px 5px violet;'>Text-shadow</option>" +
						"</select>",
						"{|}",
						"",
						"false",
						"true"
					),					
					new Array /* Separator */
					(
						Separator,
						"{|}",
						"{|}"
					),
					new Array /* Color picker HTML */
					(
						"<span class='Color Icon' title='" + Language.ToolbarColorPicker + "' name='OMToolbarColor' style='background-color:navy;' onclick=\"" + ToolbarJS + ToolbarColorHTJS + ">&nbsp;</span> <select class='ColorSelect'>" +
							"<option disabled selected>" + Language.Colors + "</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: maroon'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: red'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: orange'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: navy'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: blue'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: aqua'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: teal'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: green'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: lime'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: olive'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: gold'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: yellow'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: gray'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: silver'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: purple'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: fuchsia'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: violet'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorHTJS + " style='background-color: pink'>&nbsp;</option>" +
						"</select>",
						"{|}",
						"",
						"false",
						"true"
					),
					new Array /* Color picker */
					(
						"<span class='Color Icon' title='" + Language.ToolbarColorPicker + "' name='OMToolbarColor' style='background-color:navy;' onclick=\"" + ToolbarJS + ToolbarColorJS + ">&nbsp;</span> <select class='ColorSelect'>" +
							"<option disabled selected>" + Language.Colors + "</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: maroon'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: red'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: orange'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: navy'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: blue'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: aqua'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: teal'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: green'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: lime'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: olive'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: gold'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: yellow'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: gray'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: silver'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: purple'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: fuchsia'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: violet'>&nbsp;</option>" +
							"<option onclick=\"" + ToolbarJS + ToolbarColorJS + " style='background-color: pink'>&nbsp;</option>" +
						"</select>",
						"",
						"{|}",
						"false",
						"true"
					),
					new Array /* Separator */
					(
						Separator,
						"{|}",
						""
					),
					new Array /* Emoticons */
					(
						"<img alt='' src='http://static4.orkut.com/img/"+IsSmilyey+"i_bigsmile.gif' class='Emoticon Icon' title='" + Language.ToolbarEmoticons + "' name='OMToolbarEmoticon' value=':)' onclick=\"" + ToolbarJS + ToolbarEmoticonJS + "(x.options[x.selectedIndex].getAttribute('href'));\" /> " +
						"<select name='OMToolbarEmoticonSelect' class='EmoticonSelect'>" +
							"<option href='http://static4.orkut.com/img/"+IsSmilyey+"i_smile.gif' disabled selected value='xD'>Emoticons</option>" +
							"<option href='http://static4.orkut.com/img/"+IsSmilyey+"i_smile.gif' onclick=\"" + ToolbarJS + ToolbarEmoticonJS + "'http://static4.orkut.com/img/"+IsSmilyey+"i_smile.gif';\" style='background-image: url(http://static4.orkut.com/img/"+IsSmilyey+"i_smile.gif); background-repeat: no-repeat; background-position: left; padding-left: 20px;'>:)</option>" +
							"<option href='http://static4.orkut.com/img/"+IsSmilyey+"i_wink.gif' onclick=\"" + ToolbarJS + ToolbarEmoticonJS + "'http://static4.orkut.com/img/"+IsSmilyey+"i_wink.gif';\" style='background-image: url(http://static4.orkut.com/img/"+IsSmilyey+"i_wink.gif); background-repeat: no-repeat; background-position: left; padding-left: 20px;'>;)</option>" +
							"<option href='http://static4.orkut.com/img/"+IsSmilyey+"i_bigsmile.gif' onclick=\"" + ToolbarJS + ToolbarEmoticonJS + "'http://static4.orkut.com/img/"+IsSmilyey+"i_bigsmile.gif';\" style='background-image: url(http://static4.orkut.com/img/"+IsSmilyey+"i_bigsmile.gif); background-repeat: no-repeat; background-position: left; padding-left: 20px;'>:D</option>" +
							"<option href='http://static4.orkut.com/img/"+IsSmilyey+"i_funny.gif' onclick=\"" + ToolbarJS + ToolbarEmoticonJS + "'http://static4.orkut.com/img/"+IsSmilyey+"i_funny.gif';\" style='background-image: url(http://static4.orkut.com/img/"+IsSmilyey+"i_funny.gif); background-repeat: no-repeat; background-position: left; padding-left: 20px;'>:P</option>" +
							"<option href='http://static4.orkut.com/img/"+IsSmilyey+"i_confuse.gif' onclick=\"" + ToolbarJS + ToolbarEmoticonJS + "'http://static4.orkut.com/img/"+IsSmilyey+"i_confuse.gif';\" style='background-image: url(http://static4.orkut.com/img/"+IsSmilyey+"i_confuse.gif); background-repeat: no-repeat; background-position: left; padding-left: 20px;'>/)</option>" +
							"<option href='http://static4.orkut.com/img/"+IsSmilyey+"i_cool.gif' onclick=\"" + ToolbarJS + ToolbarEmoticonJS + "'http://static4.orkut.com/img/"+IsSmilyey+"i_cool.gif';\" style='background-image: url(http://static4.orkut.com/img/"+IsSmilyey+"i_cool.gif); background-repeat: no-repeat; background-position: left; padding-left: 20px;'>8)</option>" +
							"<option href='http://static4.orkut.com/img/"+IsSmilyey+"i_surprise.gif' onclick=\"" + ToolbarJS + ToolbarEmoticonJS + "'http://static4.orkut.com/img/"+IsSmilyey+"i_surprise.gif';\" style='background-image: url(http://static4.orkut.com/img/"+IsSmilyey+"i_surprise.gif); background-repeat: no-repeat; background-position: left; padding-left: 20px;'>:o</option>" +
							"<option href='http://static4.orkut.com/img/"+IsSmilyey+"i_sad.gif' onclick=\"" + ToolbarJS + ToolbarEmoticonJS + "'http://static4.orkut.com/img/"+IsSmilyey+"i_sad.gif';\" style='background-image: url(http://static4.orkut.com/img/"+IsSmilyey+"i_sad.gif); background-repeat: no-repeat; background-position: left; padding-left: 20px;'>:(</option>" +
							"<option href='http://static4.orkut.com/img/"+IsSmilyey+"i_angry.gif' onclick=\"" + ToolbarJS + ToolbarEmoticonJS + "'http://static4.orkut.com/img/"+IsSmilyey+"i_angry.gif';\" style='background-image: url(http://static4.orkut.com/img/"+IsSmilyey+"i_angry.gif); background-repeat: no-repeat; background-position: left; padding-left: 20px;'>:x</option>" +
						"</select>",
						"{|}",
						"{|}",
						"false",
						"true"
					),
					new Array /* Emoticons 2 */
					(
						"<img alt='' src='http://static4.orkut.com/img/i_bigsmile.gif' class='Emoticon Icon' title='" + Language.ToolbarEmoticons + "' name='OMToolbarEmoticon2' value=':)' onclick=\"" + ToolbarJS + ToolbarEmoticonJS2 + "(x.options[x.selectedIndex].getAttribute('href'));\" /> " +
						"<select name='OMToolbarEmoticonSelect2' class='EmoticonSelect'>" +
							"<option href='http://static4.orkut.com/img/i_bigsmile.gif' disabled selected value='xD'>Emoticons</option>" +
							EmoteList +
						"</select>",
						"{|}",
						"",
						"false",
						"true"
					),					
					new Array /* Separator */
					(
						Separator,
						"{|}",
						""
					),
					new Array /* Fonts */
					(
						"<span title='" + Language.ToolbarFont + "' class='Font Icon' onclick=\"" + ToolbarJS + ToolbarFontJSIconClick + "\">&nbsp;</span> " +
						"<select name='OMToolbarFontIcon' class='FontSelect' value='Arial'>" +
						"<option disabled selected value='Arial'>" + Language.Fonts + "</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Arial'>Arial</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Arno Pro'>Arno Pro</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Book Antiqua'>Book Antiqua</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Bookman Old Style'>Bookman Old Style</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Calibri'>Calibri</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Comic Sans MS'>Comic Sans MS</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Diablo'>Diablo</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Final Fantasy '>Final Fantasy</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: MS Mincho'>MS Mincho</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Ninja Naruto'>Ninja Naruto</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Sand'>Sand</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Tahoma'>Tahoma</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Time New Roman'>Time New Roman</option>" +
						"<option onclick=\"" + ToolbarJS + ToolbarFontJS + " style='font-family: Verdana'>Verdana</option>" +
						"</select>",
						"{|}",
						"",
						"false",
						"true"
					),
					new Array /* Font Size */
					(
						"<span title='" + Language.ToolbarFontSize + "' class='FontSize Icon' onclick=\"" + ToolbarJS + ToolbarFontSizeJSIconClick + "\">&nbsp;</span> " +
						"<select name='OMToolbarFontSizeIcon' class='FontSizeSelect'>" +
						"<option style='font-size:0px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">0</option>" +
						"<option style='font-size:6px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">6</option>" +
						"<option style='font-size:8px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">8</option>" +
						"<option style='font-size:10px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">10</option>" +
						"<option style='font-size:11px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\" selected>11</option>" +
						"<option style='font-size:12px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">12</option>" +
						"<option style='font-size:14px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">14</option>" +
						"<option style='font-size:16px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">16</option>" +
						"<option style='font-size:18px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">18</option>" +
						"<option style='font-size:20px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">20</option>" +
						"<option style='font-size:22px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">22</option>" +
						"<option style='font-size:26px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">26</option>" +
						"<option style='font-size:30px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">30</option>" +
						"<option style='font-size:36px;' onclick=\"" + ToolbarJS + ToolbarFontSizeJS + "\">36</option>" +
						"</select>",
						"{|}",
						"",
						"false",
						"true"
					),
					new Array /* Font Grow */
					(
						"<div style='float: left; width: 2px;'>&nbsp;</div>" +
						"<span title='" + Language.ToolbarFontG + "' class='FontGrow Icon'>&nbsp;</span>",
						"<big>{|}</big>",
						""
					),
					new Array /* Font Shrink */
					(
						"<span title='" + Language.ToolbarFontS + "' class='FontShrink Icon'>&nbsp;</span>",
						"<small>{|}</small>",
						""
					)
				),
				
			Create: // 1- HTML   2/0- Normal
			function (Id, Mode, window, rejectSetup)
			{
				if (!Id) Id = "messageBody";
				if (Mode != 1 && Mode != 2) Mode = 2;

				var el = window.document.getElementById(Id);
				if (!el) return;
				el.style.width = "100%";
				el.parentNode.style.width = "99%";

				var b, e, s, sel;
				if (OMSystem.OrkutManager.Util.Window.IsPage("/Scrapbook", window))
				{
                    b = (Mode == 1) ? User.SHColorB : User.SColorB;
					e = (Mode == 1) ? User.SHColorE : User.SColorE;
					s = (Mode == 1) ? User.SHSignature : User.SSignature;
				}
				else
				{
					b = (Mode == 1) ? User.HColorB : User.ColorB;
					e = (Mode == 1) ? User.HColorE : User.ColorE;
					s = (Mode == 1) ? User.HSignature : User.Signature;
					
					sel = el.value.length + b.length;
				}

				// setup & focus
				if (!rejectSetup)
				{
					el.value += b;
					sel = el.value.length;
					el.value += e;
					el.value += (s != "" ? ("\n\n" + s) : "");
				}
				if (!el.id.match(/scrapText_\d+/) && !rejectSetup)
				{
					try
					{
						el.selectionStart = el.selectionEnd = sel;
						el.focus();
					}
					catch (ex) { }
				}

				var items = "";
				for (i = 0; i < this.Tools.length; ++i)
				{
					var ToolAuto = true;
					if (this.Tools[i][Mode].length == 0) continue;
					if (this.Tools[i].length > 3) ToolAuto = (this.Tools[i][3] != "false");
					var extra = (this.Tools[i].length > 4 && this.Tools[i][4] == "true") ? "float:left;border: 1px solid silver;width:auto;margin: 0px 2px" : "";
					items += "<span style='vertical-align:middle; " + extra + "' onmouseover=\"this.title= this.firstChild.title!='' ? this.firstChild.title : 'OMToolbar';\" ";
					items +=
						"onclick=\"" + "var TextArea = document.getElementById('" + Id + "'); "
						+ "var TextSelected = TextArea.value.substr((TextArea.selectionStart), (TextArea.selectionEnd - TextArea.selectionStart));";
						
					if (ToolAuto)
							items += "TextArea.value = TextArea.value.substr(0, TextArea.selectionStart) + '" +
							this.Tools[i][Mode] +
							"' + TextArea.value.substr(TextArea.selectionEnd); var focus = TextArea.value.lastIndexOf('{|}');" +
							"TextArea.value = TextArea.value.replace('{|}', TextSelected);" + 
							"TextArea.selectionStart = focus; TextArea.selectionEnd = focus + TextSelected.length;" +
							"TextArea.focus(); TextArea.scrollTop = (14 * TextArea.value.substr(0, TextArea.selectionStart).match(/\\n/g).length); ";
					items += "\">" + (this.Tools[i][0]) + "</span> ";
				}
				var Sep = window.document.createElement("div"); Sep.style.lineHeight = "5px";
				var Bar = window.document.createElement("div"); Bar.id = "OMToolBar" + Id; Bar.className = "OMToolbar";
				Bar.innerHTML = items;
				window.document.getElementById(Id).parentNode.insertBefore(Sep, window.document.getElementById(Id));
				window.document.getElementById(Id).parentNode.insertBefore(Bar, Sep);
			}
		};

		ToolbarFontJS = null;
		ToolbarFontSizeJS = null;
		ToolbarHighlightJS = null;
		ToolbarColorHTJS = null;
		ToolbarColorJS = null;
		ToolbarEmoticonJS = null;
		ToolbarNewLine = null;
		ToolbarJS = null;

		return Toolbar;
	}
};
